<?php
if (!defined('ROOT_PATH')) {
   define('ROOT_PATH',dirname(dirname(dirname(__FILE__))));
}

if (!defined('ROOT_PATH_TESTDIR')) {
define('ROOT_PATH_TESTDIR',ROOT_PATH.'/unit_testing/tests/temp/testFolder');
}

class Tools{
	static public function removeDirRecursive($dir_name){
		$handle = opendir($dir_name);
		while (false !== ($file = readdir($handle))){		
			if($file=='.' || $file=='..') continue;
			$path = $dir_name.'/'.$file;
			if(is_dir($path)){
				Tools::removeDirRecursive($path);
			}else{
				unlink($path);
			}
		}
		rmdir($dir_name);	
	}
	
	static public function copyDirRecursive($dir_source, $dir_destination){
		$handle = opendir($dir_source);
		
		if (!is_dir($dir_destination)) {
			mkdir($dir_destination);
		}
		
		while (false !== ($file = readdir($handle))){		
			if($file=='.' || $file=='..') continue;
			$path_source = $dir_source.'/'.$file;
			$path_destination = $dir_destination.'/'.$file;
			if(is_dir($path_source)){
				Tools::copyDirRecursive($path_source,$path_destination);
			}else{
				copy($path_source, $path_destination);
			}
		}
	}

}

?>
